--jobsystem.lua
--Main job system file

jobs = {}

function addJob(id, name, desc, wage, limit, voted, jobCheckFunc, jobVisibleFunc)	--Creates a new job
	local newJob = {}
	newJob.id = id
	newJob.name = name
	newJob.desc = desc
	newJob.wage = wage
	newJob.limit = limit
	newJob.voted = voted
	newJob.jobCheckFunc = jobCheckFunc
	newJob.jobVisibleFunc = jobVisibleFunc
	jobs[id] = newJob
end

function getJobInfo(id)	--Returns information on job of id
	return jobs[id]
end

--Add Player:GetJob() and Player:SetJob(job)
local playermt = FindMetaTable("Player")

function playermt:GetJob()
	return self:GetNetworkedInt("job")
end

function playermt:SetJob(job)
	self:SetNetworkedInt("job", job)
end

--Set player to citizen when they join
hook.Add("PlayerInitialSpawn", "setPlayerToCitizenOnJoin", function(plr)
	plr:SetJob(1)
end)

--Add setjob ConCommand
concommand.Add("setjob", function(plr, cmd, args)
	--if #args ~= 1 then return end
	local newJobId = args[1]
	--if jobs[newJobId] == nil then return end
	--TODO: Add voting checks, limit checks, etc.
	plr:SetJob(newJobId)
end)
